From: David Härdeman Date: Fri, 17 Oct 2025 19:45:38 +0000 (+0200) Subject: odhcpd: shrink binary size by creating a logging function X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=ff3a241ccc98a19bae6a6be271055dec108a9679;p=project%2Fodhcpd.git odhcpd: shrink binary size by creating a logging function Moving the logging to a real function helps shrink the binary size back to what it was before the logging patches. Signed-off-by: David Härdeman Link: https://github.com/openwrt/odhcpd/pull/273 Signed-off-by: Álvaro Fernández Rojas --- diff --git a/src/odhcpd.c b/src/odhcpd.c index 1f3cd1b..4b17a16 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -46,6 +46,25 @@ static int ioctl_sock = -1; static int urandom_fd = -1; +void __iflog(int lvl, const char *fmt, ...) +{ + va_list ap; + + if (lvl > config.log_level) + return; + + va_start(ap, fmt); + + if (config.log_syslog) { + vsyslog(lvl, fmt, ap); + } else { + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + } + + va_end(ap); +} + static void sighandler(_unused int signal) { uloop_end(); diff --git a/src/odhcpd.h b/src/odhcpd.h index 9a41a59..dc77c03 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -69,16 +69,7 @@ struct nl_sock; extern struct vlist_tree leases; extern struct config config; -#define __iflog(lvl, fmt, ...) \ - do { \ - if (lvl > config.log_level) \ - break; \ - if (config.log_syslog) \ - syslog(lvl, fmt __VA_OPT__(, ) __VA_ARGS__); \ - else \ - fprintf(stderr, fmt "\n" __VA_OPT__(, ) __VA_ARGS__); \ - } while(0) - +void __iflog(int lvl, const char *fmt, ...); #define debug(fmt, ...) __iflog(LOG_DEBUG, fmt __VA_OPT__(, ) __VA_ARGS__) #define info(fmt, ...) __iflog(LOG_INFO, fmt __VA_OPT__(, ) __VA_ARGS__) #define notice(fmt, ...) __iflog(LOG_NOTICE, fmt __VA_OPT__(, ) __VA_ARGS__)